/*
 * SplashPropertiesFrame.java
 *
 * Created on March 2, 2005, 12:40 PM
 */
package com.bff.bjj.ui;

import com.bff.bjj.AbstractJukeboxProperties;
import com.bff.bjj.ui.component.BJJDialog;
import com.bff.bjj.utils.BrowserLauncher;
import com.bff.bjj.utils.Resources;
import javax.swing.JFrame;

/**
 *
 * @author  findeisb
 */
public class UpdateSplashDialog extends BJJDialog {

    private AbstractJukeboxProperties jukeboxProperties;

    /** Creates new form SplashPropertiesFrame */
    public UpdateSplashDialog(JFrame parent, AbstractJukeboxProperties jp) {
        super(parent);
        this.jukeboxProperties = jp;

        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new com.bff.bjj.ui.component.BJJPanel();
        btnGetUpdate = new com.bff.bjj.ui.component.BJJButton();
        btnProceed = new com.bff.bjj.ui.component.BJJButton();
        jPanel2 = new com.bff.bjj.ui.component.BJJPanel();
        messageTextArea = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(getResource(Resources.LABEL_KEY.UPDATE_TITLE));

        btnGetUpdate.setText(getResource(Resources.LABEL_KEY.UPDATE_BUTTON_GET));
        btnGetUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGetUpdateActionPerformed(evt);
            }
        });
        jPanel1.add(btnGetUpdate);

        btnProceed.setText(getResource(Resources.LABEL_KEY.UPDATE_BUTTON_CONTINUE));
        btnProceed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnProceedActionPerformed(evt);
            }
        });
        jPanel1.add(btnProceed);

        getContentPane().add(jPanel1, java.awt.BorderLayout.SOUTH);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        messageTextArea.setText(getResource(Resources.LABEL_KEY.UPDATE_TEXT));
        messageTextArea.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        jPanel2.add(messageTextArea, new java.awt.GridBagConstraints());

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void btnGetUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGetUpdateActionPerformed
        BrowserLauncher.openURL(getJukeboxProperties().getUpdateURL());
        System.exit(0);
}//GEN-LAST:event_btnGetUpdateActionPerformed

    private void btnProceedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProceedActionPerformed
        new Thread(new Runnable() {

            @Override
            public void run() {
               getJukeboxProperties().notifiedOfUpdate();
            }
        }).start();

        dispose();
}//GEN-LAST:event_btnProceedActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGetUpdate;
    private javax.swing.JButton btnProceed;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextArea messageTextArea;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the jukeboxProperties
     */
    private AbstractJukeboxProperties getJukeboxProperties() {
        return jukeboxProperties;
    }
}
